package problem;

import java.util.Enumeration;
import java.util.Vector;

import weka.core.Attribute;
import weka.core.Instances;
import weka.core.converters.ConverterUtils.DataSource;

public class Metalearning {
	
	private DataSource source;
	private Instances data;

	public Metalearning() {

	}

	public void loadARFF(String filePath) {
		try {
			source = new DataSource(filePath);
			data = source.getDataSet();
			// setting class attribute if the data format does not provide this information
			// For example, the XRFF format saves the class attribute information as well
			if (data.classIndex() == -1)
				data.setClassIndex(data.numAttributes() - 1);
			retrieveAttributes();
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	
	public Vector<String> retrieveAttributes() {
		Enumeration<Attribute> attributes = data.enumerateAttributes();
		Vector<String> attributes_str = new Vector<String>();
		while (attributes.nextElement() != null) {
			attributes_str.add(attributes.toString());
		}
		return attributes_str;
	}
}
